//
//  PlanTypeArrowView.m
//  WanCaiC8
//
//  Created by tangang on 2018/3/7.
//  Copyright © 2018年 tangang. All rights reserved.
//

#import "PlanTypeArrowView.h"

@implementation PlanTypeArrowView{
    BOOL    open;
    UIImageView *imageV;
    UIView *line;
}

- (instancetype)initWithFrame:(CGRect)frame{
    if (self=[super initWithFrame:frame]) {
        WS(weakSelf);
        
        UITapGestureRecognizer *tap=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(onclickTap:)];
        [self addGestureRecognizer:tap];
        line=[[UIView alloc]init];
        line.backgroundColor=DEFAULTBGCOLOR;
        [self addSubview:line];
        [line mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.top.equalTo(weakSelf);
            make.height.mas_equalTo(@.7);
        }];
        imageV =[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"arrow_bottom"]];
        [self addSubview:imageV];
        [imageV mas_makeConstraints:^(MASConstraintMaker *make) {
            make.center.equalTo(weakSelf);
            make.size.mas_equalTo(imageV.image.size);
        }];
    }
    return self;
}

- (void)setOpen:(BOOL)isOpen{
    open=isOpen;
    line.hidden=isOpen;
    if (isOpen) {
        imageV.image=[UIImage imageNamed:@"arrow_top"];
    }else{
        imageV.image=[UIImage imageNamed:@"arrow_bottom"];
    }
}

- (void)onclickTap:(UITapGestureRecognizer *)tap{
    if (self.openBlock) {
        self.openBlock(!open);
    }
}

@end
